package com.jy.adscm.zltx.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.zltx.bean.QsUpdateHistoryRecord;
import com.jy.adscm.zltx.mapper.mysql.QsUpdateHistoryRecordMapper;
import com.jy.adscm.zltx.service.QsUpdateHistoryRecordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-02
 */
@Service
public class QsUpdateHistoryRecordServiceImpl extends ServiceImpl<QsUpdateHistoryRecordMapper, QsUpdateHistoryRecord> implements QsUpdateHistoryRecordService {
    @Autowired
    QsUpdateHistoryRecordMapper QsUpdateHistoryRecordMapper;
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<QsUpdateHistoryRecord> selectByUpdateId(Integer updateId) {
        Wrapper<QsUpdateHistoryRecord> wrapper =new EntityWrapper<>();
        wrapper.eq("updateId",updateId);
        List<QsUpdateHistoryRecord> qsUpdateHistoryRecords = QsUpdateHistoryRecordMapper.selectList(wrapper);
        for (QsUpdateHistoryRecord qsUpdateHistoryRecord : qsUpdateHistoryRecords) {
            if (qsUpdateHistoryRecord.getFileUpdateWriter()!=null&&!"".equals(qsUpdateHistoryRecord.getFileUpdateWriter())){
                JyUser jyUser = jyUserMapper.selectById(qsUpdateHistoryRecord.getFileUpdateWriter());
                qsUpdateHistoryRecord.setFileUpdateWriterName(jyUser.getName());
            }
        }
        return qsUpdateHistoryRecords;
    }


}
